Attribute VB_Name = "RTAids_FROM_REPORT"
'_______________________________________________________________________________________________________________
'***************************************************************************************************************
'
'   File:   RTAids_FROM_REPORT
'
'_______________________________________________________________________________________________________________
'***************************************************************************************************************






'____________________________________________________________________________________________________
'====================================================================================================
'   Sub: RTAidsFROMreport
'       Extracts the RTA number and CWI jID from the CWI IncompleteRTAreport in its default format.
'       After extracting, the part ID ini file is opened so that the new values can be added.
'
'   Parameters:
'       None
'
'   Returns:
'       None
'
'   General Info:
'
'       > Written by:       Rameen Bakhtiary
'       > Date Modified:    11/28/2011
'====================================================================================================
Sub RTAidsFROMreport()
    i = 2
    
    'Put "XXXXXX=[partID]" into col B for every RTA
    '=======================================
    While Cells(i, 1) <> ""
        Range("B" & i) = _
            Right(Cells(i, 1), 6) & "=" & Right(Range("a" & i).Hyperlinks(1).Address, _
            Len(Range("a" & i).Hyperlinks(1).Address) - 52)
        i = i + 1
    Wend
    
    ' Cut / Paste data to new sheet and open INI file
    '=======================================
    Range("B2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    ActiveWindow.ScrollWorkbookTabs Position:=xlLast
    Sheets.Add After:=Sheets(Sheets.Count)
    ActiveSheet.Range("A1").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    ActiveCell.SpecialCells(xlLastCell).Offset(1, 0).Select
    
    
    ' Create button that will continue after pasting from INI
    '=============================================================
    ActiveSheet.Buttons.Add(244.5, 7197, 83.25, 31.5).Select
    Selection.OnAction = "keepGoing"
    Selection.Caption = "Resume"
    
    
    ' Open the RtaIDs INI File & wait for button to b pressed
    '============================================================
    Call Shell("notepad.exe \\corp.halliburton.com\team\WD\Business Development and Technology\General\Engineering Public\PM App Logs\StrMgmtLks\rtaid.ini")
        
End Sub



'===================================================
'              Pressed the 'Resume' button
'===================================================
Sub keepGoing()

    Range("a1").Select
    Range(Selection, Selection.End(xlDown)).Select
   
        
    Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.RemoveDuplicates Columns:=1, Header:=xlNo
    
    
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("A1"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        
        
    With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SetRange Selection
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    
    Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
End Sub




